import PySimpleGUI as sg

def ps1():pass

def msgbox(*msg,
        title = "XToolsBox+",
        ok = "OK"):
    message = ""
    for m in msg:
        message += str(m)
        message += " "
    ok_btn = sg.Button(ok,key = "ok")
    layout = []
    layout += [[sg.Text(message)]]
    layout += [[ok_btn]]
    print(layout)
    window = sg.Window(title,layout)
    while True:
        event,value = window.read()
        if event == sg.WIN_CLOSED:break
        if event == "ok":break
    window.close()
    return True

def twoButton(*msg,
        title = "XToolsBox+",
        ok = "OK",
        cancel = "Cancel"):
    message = ""
    for m in msg:
        message += str(m)
        message += " "
    ok_btn = sg.Button(ok,key = "ok")
    cl_btn = sg.Button(cancel,key = "qs")
    layout = []
    layout += [[sg.Text(message)]]
    layout += [[ok_btn,cl_btn]]
    print(layout)
    re = None
    window = sg.Window(title,layout)
    while True:
        event,value = window.read()
        if event == sg.WIN_CLOSED:break
        if event == "ok":
            re = True
            break
        if event == "qs":
            re = False
            break
    window.close()
    return re

def InputLine(*msg,
        title = "XToolsBox+",
        ok = "OK",
        cancel = "Cancel"):
    message = ""
    for m in msg:
        message += str(m)
        message += " "
    ok_btn = sg.Button(ok,key = "ok")
    cl_btn = sg.Button(cancel,key = "qs",)
    layout = []
    il = sg.InputText()
    layout += [[sg.Text(message)]]
    layout += [[sg.InputText()]]
    layout += [[ok_btn,cl_btn]]
    print(layout)
    re = None
    window = sg.Window(title,layout)
    #il.SetFocus(True)
    while True:
        event,value = window.read()
        if event == sg.WIN_CLOSED:break
        if event == "ok":
            re = value[0] 
            break
        if event == "qs":
            break
    window.close()
    return re

def Multiline(*msg,
        title = "XToolsBox+",
        ok = "OK",
        cancel = "Cancel"):
    message = ""
    for m in msg:
        message += str(m)
        message += " "
    ok_btn = sg.Button(ok,key = "ok")
    cl_btn = sg.Button(cancel,key = "qs",)
    layout = []
    #il = sg.InputText()
    layout += [[sg.Text(message)]]
    layout += [[sg.Multiline(size = (48,7))]]
    layout += [[ok_btn,cl_btn]]
    print(layout)
    re = None
    window = sg.Window(title,layout)
    #il.SetFocus(True)
    while True:
        event,value = window.read()
        if event == sg.WIN_CLOSED:break
        if event == "ok":
            re = value[0] 
            break
        if event == "qs":
            break
    window.close()
    return re

#print(Multiline("请输入您的用户名"))
